﻿namespace DBUtil;

/// <summary>
/// 数据库类型
/// </summary>
public enum EnumDBType
{
    SqlServer = 0,
    MySql = 1,
    Oracle = 2,
    PostgreSql = 3,
    Sqlite = 4,
}

/// <summary>
/// 数据库版本的兼容性, 生成sql的时候会有帮助
/// </summary>
public enum EnumDBVersionCompatibility
{
    //sqlserver
    SqlServer2008Compatible = 0,
    SqlServer2012Compatible = 1,
    SqlServer2014Compatible = 2,
    SqlServer2016Compatible = 3,
    SqlServer2017Compatible = 4,
    SqlServer2019Compatible = 5,
    SqlServer2022Compatible = 6,

    //mysql
    Mysql8Compatible = 10,
    Mysql9Compatible = 11,

    //postgresql

    //oracle

    //sqlite
}

public enum EnumInsertToSql
{
    /// <summary>
    /// 执行并返回受影响的行数
    /// </summary>
    ExecuteAffrows,
    /// <summary>
    /// 执行并返回自增主键
    /// </summary>
    ExecuteIdentity,
    /// <summary>
    /// 执行并返回新增的数据
    /// </summary>
    ExecuteInserted
}

/// <summary>
/// insert构建器类型
/// </summary>
public enum EnumInsertBuilderType
{
    InsertByDictionary,
    InsertByEntity,
    InsertByDto,
}

internal enum EnumSetIgnoreType
{
    SetColumn,
    IgnoreColumn,
    OnlyColumn
}

public enum EnumDeleteBuilderType
{
    Delete,
    DeleteByPrimary
}

public enum EnumUpdateBuilderType
{
    UpdateByDictionary,
    UpdateByEntity,
    UpdateByDto,
    UpdateByExpression
}

public enum EnumSelectToSql
{
    ToList,
    ToPage,
    Count,
    Max,
    Min,
    Sum,
    Avg,

    ToSelectClause,
}

public enum EnumJsonDataType
{
    String,
    Number,
    Null,
    Bool,
    Object,
    Array,
}

/// <summary>
/// sql中目标位置需要的json类型,如:
/// <list type="bullet">
/// <item>null: doc[null], value(null)</item>
/// <item>number: doc[cast(1 as json)], value(1)</item>
/// <item>bool: doc[cast(true as json)], value(true)</item>
/// <item>string: doc['"tom"'], value('tom')</item>
/// <item>arr/obj: doc['[1,2]'], value(cast('[1,2]' as json))</item>
/// </list>
/// </summary>
/// <remarks>
/// 注意: 函数或sql的某个地方有声明接受的是 json_doc 或 val, 如 mysql 中:
/// <list type="bullet">
/// <item>JSON_ARRAY([val[, val] ...])</item>
/// <item>JSON_ARRAY_APPEND(json_doc, path, val[, path, val] ...)</item>
/// <item>JSON_OVERLAPS(json_doc1, json_doc2)</item>
/// <item>set ext(json column)=json_doc</item>
/// </list>
/// 最好按照函数声明的类型传递, 否则会发生意外, 如:
/// <list type="bullet">
/// <item>正常: select json_array_append('[1,2]','$',cast('{"name":"ko"}' as json))</item>
/// <item>意外: 追加的变成了字符串 select json_array_append('[1,2]','$','{"name":"ko"}')</item>
/// </list>
/// </remarks>
public enum EnumJsonAcceptAsType
{
    Value,
    Doc,
    /// <summary>
    /// 供 db.Insert()...ToDataTable() 使用
    /// </summary>
    DataTableValue,
}

public enum EnumJoinType
{
    LeftJoin,
    RightJoin,
    InnerJoin,
    CrossJoin,
}

public enum EnumTreeSpreedMode
{
    Both,
    Sub,
    Parent,
}

internal enum EnumLikeMode
{
    Start,
    End,
    Both,
}

public enum EnumKeyStrategy
{
    /// <summary>
    /// 自定义，插入时必须手动指定值，默认
    /// </summary>
    Custom,
    /// <summary>
    /// 自增
    /// <list type="number">
    /// <item>sqlserver：identity(1,1)</item>
    /// <item>mysql：auto_increment</item>
    /// </list>
    /// </summary>
    Identity
}